import cv2
import matplotlib.pyplot as plt
import numpy as np


def show(img):
    cv2.imshow("img", img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

img = cv2.imread("./01_Picture/01_cat.jpg")
# 截取部分图像数据
cat = img[0:200, 0:200]
show(cat)
# 切分rgb
b, g, r = cv2.split(img)
show(b)
show(g)
show(r)
# 合并rgb
img = cv2.merge((b, g, r))
show(img)
# 只保留R
cur_img = img.copy()
cur_img[:,:,0] = 0
cur_img[:,:,1] = 0
show(cur_img)
# 只保留G
cur_img = img.copy()
cur_img[:,:,0] = 0
cur_img[:,:,2] = 0
show(cur_img)
# 只保留B
cur_img = img.copy()
cur_img[:,:,1] = 0
cur_img[:,:,2] = 0
show(cur_img)
